<?php
class KeyAction {
    public static $delkey = "delete";
    public static $showkey = "show";
    public static $displaykey = "display";
    public static $refillkey = "refill";
    public static $updatekey = "update";
}

function idEncode($action, $id) {
    return base64_encode("$action::" . base64_encode($id . " " . md5($id)));
}

function idDecode($action, $id) {
    $decode = explode("::", base64_decode($id));
    if (count($decode) != 2) {
        return FALSE;
    }
    if ($decode[0] != $action) {
        return FALSE;
    }
    $decode2 = explode(" ", base64_decode($decode[1]));
    if (count($decode2) != 2) {
        return FALSE;
    }
    if ($decode2[1] == md5($decode2[0])) {
        return addslashes(strip_tags($decode2[0]));
    } else {
        return FALSE;
    }
}